import logging
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
from WMS_unittest.tools_unit import Tools
import unittest

class Wms(unittest.TestCase):
    def setUp(self) -> None:
        Tools().log1()
        self.driver = webdriver.Edge()
        self.driver.get('http://10.59.9.32/jeewms/loginController.do?login')
        self.driver.maximize_window()
        sleep(2)

    def tearDown(self) -> None:
        sleep(5)
        self.driver.quit()

    def test_admin_car(self):

        logging.info("*****************************************")
        try:
            # 运输管理-派车管理
            sleep(5)
            self.driver.find_element(By.ID, 'but_login').click()
            sleep(2)
            self.driver.find_element(By.XPATH, '//*[@id="sidebar"]/ul/li[8]/a/span').click()
            sleep(2)
            self.driver.find_element(By.XPATH, '//*[@id="sidebar"]/ul/li[8]/ul/li[4]/a').click()
            sleep(2)
            self.driver.switch_to.frame(
                self.driver.find_element(By.XPATH, '//*[@id="tab_4028818469d64a0b0169d64e956d000b"]/iframe'))
            self.driver.find_element(By.NAME, 'fahuoren').send_keys('老王')
            self.driver.find_element(By.NAME, 'shouhuoren').send_keys('小高先生')
            self.driver.find_element(By.NAME, 'siji').send_keys('一只耳')
            dy = self.driver.find_element(By.XPATH,
                                           '/html/body/div/div[1]/div/div/div[2]/div[2]/div[2]/div[1]/div/table/tbody/tr/td[11]/div/span[1]').text
            print(dy)
            self.assertIn(dy, '发货人地址')
            sleep(5)
            logging.info("*****************************************")
        except Exception as e:
            print(e)


if __name__ == '__main__':
    unittest.main()
